package cc.owoo.godpen.network.http;

/**
 * HTTP服务器工具类
 * Created by nimensei
 * 2022-04-11 下午 02:57
 **/
public class HttpServerUtil {
    /**
     * 处理跨域
     *
     * @param request  请求头
     * @param response 响应头
     */
    public static void cors(Request request, Response response) {
        String origin = request.getHeader("Origin");
        if (origin == null)
            return;
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with,Content-Type");
        response.setHeader("Access-Control-Allow-Origin", origin);
        response.setHeader("Access-Control-Allow-Methods", "POST,GET");
    }
}
